/**
 * tigerrad
 * fall 2006
 */

#ifndef _CAMERA_H
#define _CAMERA_H

#include "Util.h"

/**
 * Simple Camera class...
 */
class Camera
{
	public:
		/**
		 * Constructor.  Sets values to default OpenGL camera.
		 */
		Camera() : _pos(Vec3(0,0,0)), _dir(0,0,-1), _up(0,1,0), _fovy(45.0)
		{ init(); }

		/**
		 * Constructor.
		 */
		Camera(const Vec3& p, const Vec3& d, const Vec3& u, float fovy) 
			: _pos(p), _dir(d), _up(u), _fovy(fovy)
		{ init(); }

		/** Return the camera position. */
		Vec3 getPos() const { return _pos; }

		/** Return the camera direction. */
		Vec3 getDir() const { return _dir; }

		/** Return the camera up direction. */
		Vec3 getUp() const { return _up; }

		/** Return a point the camera is looking at. */
		Vec3 getAt() const { return _pos + _dir; }

		/** Return the field of view in the y direction. */
		float getFovy() const { return _fovy; }

		/**
		 * Return the view matrix of the camera.
		 */
		const Matrix& getViewMatrix() const { return _mat; }

	private:
		
		/** init the Matrix */
		void init() {
			Vec3 at = _pos+_dir;
			_mat.makeLookAt(_pos, at, _up);
		}
		
		Vec3 _pos;
		Vec3 _dir;
		Vec3 _up;
		float _fovy;

		/** The heart of the Camera for now...*/
		Matrix _mat;
};

#endif

